package view;

import javax.swing.*;

import net.miginfocom.swing.MigLayout;

import java.awt.*;


/**
 * Represents the login screen of the system.
 * 
 * @author Kenny Chong, Dan End, James Ju 
 * CSE 333 : User Interface 
 * Project HMSystem
 */
public class LoginPanel extends JPanel
{
	// Variables.
	private final String title = "Hotel Management System (HMSystem)";
	private HMSView parentFrame;
	private JLabel titleLabel;
	
	private MigLayout layout;

	/**
	 * Constructs the login panel.
	 * @param parent
	 */
	public LoginPanel(HMSView parent)
	{
		parentFrame = parent;
		
		// Initialize the panel.
		this.init();
	}
	
	/**
	 * Initialize the login panel.
	 */
	public void init()
	{
		layout = new MigLayout();
		
		this.setLayout(layout);
		
		// Title.
		titleLabel = new JLabel(title);
		titleLabel.setFont(new Font("Calibri", Font.PLAIN, 50));
		titleLabel.setForeground(new Color(0,51,204));
		
		// Add login box to center.
		this.add(titleLabel, "dock north");
		this.add(LoginBox.getLoginBox(), "pos 0.5al 0.5al");
	}
	
	/**
	 * Retrieve user name.
	 */
	public String getUserName()
	{
		return LoginBox.getLoginBox().getNameField().getText();
	}
	
	/**
	 * Retrieve password.
	 * @return
	 */
	public char[] getPassName()
	{
		return LoginBox.getLoginBox().getPasswordField().getPassword();
	}
	
	/**
	 * Reset name and password.
	 */
	public void reset()
	{
		LoginBox.getLoginBox().getNameField().setText("");
		LoginBox.getLoginBox().getPasswordField().setText("");
	}
	// Please feel free to incorporate any other methods as required.
}
